home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / printdir.zip / PWD.DOC < prev    next >
Text File  |  1993-01-04  |  3KB  |  87 lines

  1.          PWD:  Print Working Directories on All Valid Drives
  2.                            in Turbo Pascal
  3.  
  4.                                  by
  5.  
  6.                             Earl F. Glynn
  7.                           Overland Park, KS
  8.                         Compuserve 73257,3527
  9.  
  10.                (C) Copyright 1989, All Rights Reserved.
  11.  
  12.  
  13.  
  14.     File                         D e s c r i p t i o n
  15. ------------  ----------------------------------------------------------
  16. PWD.DOC       This file.
  17. PWD.PAS       Turbo Pascal source program.
  18. PWD.EXE       Executable program.
  19. PWD.OUT       Sample PWD output.
  20.  
  21.  
  22.  
  23.      Knowing all current working directories on all disk drives can
  24. shorten needed file specifications by using the path implied by the
  25. working directory.  For example, if the default drive is C:, the
  26. working directory on drive D is
  27.  
  28.           D:\TP\GRAPHICS\EXAMPLES
  29.  
  30. and the working directory on drive A is
  31.  
  32.           A:\NEW\EXAMPLES
  33.  
  34. all the pascal files from the working directory of A can be copied
  35. to the working directory of D by entering the DOS command
  36.  
  37.           COPY  A:*.PAS  D:
  38.  
  39. instead of the longer forms
  40.  
  41.           COPY  A:\NEW\EXAMPLES\*.PAS  D:\TP\GRAPHICS\EXAMPLES\*.*
  42. or
  43.           COPY  A:\NEW\EXAMPLES\*.PAS  D:\TP\GRAPHICS\EXAMPLES
  44.  
  45.  
  46.      The DOS prompt is often defined to be something like
  47.  
  48.           PROMPT $p$g        (I prefer "PROMPT $p   $t$h$h$h$_$g")
  49.  
  50. to show the current default drive and directory.  To find the working
  51. directory on drives other than the default drive, each drive must be
  52. selected and the directory displayed using either the CD command without
  53. parameters, or the DIR command.  This can be a waste of time when
  54. all the working directories are correct but an interruption in work
  55. causes a lapse in (human) memory.  On the other hand, assuming that
  56. certain working directories are defined, when in fact they are not, can
  57. lead to very serious results.  The PWD command, written in Turbo
  58. Pascal 5.0, eliminates these problems.
  59.  
  60.      To execute the program, simply enter "PWD".  The program has no
  61. parameters or options.  PWD displays all working directories on all
  62. drives.  While the program has been tested on several PC and MS DOS
  63. machines, it has only been tested with DOS 3.3.  Sample output from PWD
  64. follows:
  65.  
  66.           Working Directories:
  67.             A:\
  68.             C:\TP\LIB
  69.             D:\BBS
  70.  
  71.      My first choice in program name was SWD for "show working directory"
  72. to complement the existing DOS MD "make directory" and CD "change
  73. directory" commands.  But since UNIX already has a command called PWD
  74. to "print working directory" I decided to use that name instead.
  75.  
  76.      PWD uses a number of undocumented DOS "features".  Starting with
  77. the DOS List of Lists defined by DOS interrupt $21 function $52,
  78. information about the first "drive array" entry (BaseDA) and the number
  79. of drives (LastDrive) is found.  Each "drive array" entry is a $51-byte
  80. (decimal 81) long RECORD.  The first entry is the default or working
  81. directory of the drive in ASCIIZ format.  But the "drive array" entry is
  82. not currently valid unless the "valid" field pointed to by the DPB
  83. (Disk Parameter Block) pointer is a zero.  (Other very useful information
  84. is also defined in the Disk Parameter Block RECORD for the drive.)
  85. Each "drive array" entry is checked until the LastDrive is encountered,
  86. or the NextDPB pointer (DPB^.NextDPB^) is $FFFF.
  87.